﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bootstrap.MVC.Utils;
using System.Web.Mvc;

namespace Bootstrap.MVC.Widgets
{
    public class WidgetFactory
    {

        #region Private Properties


        private HtmlHelper htmlhelper;


        private ViewContext viewContext
        {
            get { return htmlhelper.ViewContext; }
        }

        #endregion Private ProPerties



        #region Constructors

        public WidgetFactory(HtmlHelper helper)
        {
            Guard.IsNotNull(helper, "helper");

            htmlhelper = helper;
        }

        #endregion Constaructors





        #region Component Builders

        public ButtonBuilder Button()
        {
            var model = new ButtonModel(viewContext);
            var htmlGenerator = new ButtonHtmlGenerator(model);
            var scriptGenerator = new ButtonScriptGenerator(model);
            return new ButtonBuilder(model, htmlGenerator, scriptGenerator);
        }

        public ButtonGroupBuilder ButtonGroup()
        {
            var model = new ButtonGroupModel(viewContext);
            var htmlGenerator = new ButtonGroupHtmlGenerator(model);
            var scriptGenerator = new ButtonGroupScriptGenerator(model);
            return new ButtonGroupBuilder(model, htmlGenerator, scriptGenerator);
        }

        public ButtonDropDownBuilder DropDownButton()
        {
            var model = new ButtonDropDownModel(viewContext);
            var htmlGenerator = new ButtonDropDownHtmlGenerator(model);
            var scriptGenerator = new ButtonDropDownScriptGenerator(model);
            return new ButtonDropDownBuilder(model, htmlGenerator, scriptGenerator);
        }

        public DropDownMenuBuilder DropDownMenu()
        {
            var model = new DropDownMenuModel(viewContext);
            var htmlGenerator = new DropDownMenuHtmlGenerator(model);
            var scriptGenerator = new DropDownMenuScriptGenerator(model);
            return new DropDownMenuBuilder(model, htmlGenerator, scriptGenerator);
        }

        #endregion Component Builders
    }

    public class WidgetFactory<T>
    {

        #region Private Properties
        private HtmlHelper htmlhelper;
        
        private ViewContext viewContext
        {
            get { return htmlhelper.ViewContext; }
        }
        #endregion Private ProPerties



        #region Constructors
        public WidgetFactory(HtmlHelper helper)
        {
            Guard.IsNotNull(helper, "helper");
            htmlhelper = helper;
        }
        #endregion Constaructors

        
        #region Component Builders


        //public ListBuilder<T> List()
        //{
        //    var list = new ListComponent<T>(viewContext);
        //    var htmlGenerator = new ListHtmlGenerator<T>(list);
        //    var scriptGenerator = new ListScriptGenerator<T>(list);

        //    return new ListBuilder<T>(list, htmlGenerator, scriptGenerator);
        //}

        #endregion Component Builders
    }
}
